﻿
namespace Patterns4Net.Tests.PatternEnforcer.Core.Patterns.Regression
{
    using System;
    using NUnit.Framework;
    using Patterns4Net.Core.CecilExtensions;
    using Patterns4Net.PatternEnforcer.Core.Patterns;

    [TestFixture]
    public class StrategyCheckerTest : PatternCheckerTestBase
    {
        [Test]
        [TestCase(typeof(IStrategy))]
        [TestCase(typeof(INonStrategy))]
        [TestCase(typeof(NonOverrideableStrategy))]
        [TestCase(typeof(NonPublicStrategy))]
        [TestCase(typeof(VirtualStrategy))]
        [TestCase(typeof(Strategy))]
        public void RunAllTests(Type type)
        {
            this.TestChecker(
                new StrategyChecker(), 
                type,
                new Patterns4Net.Core.Patterns.Strategy(type.GetTypeDefinition()));
        }

        [PatternTest(true)]
        public interface IStrategy
        {
            void Action();
        }

        [PatternTest(false)]
        public interface INonStrategy
        {
            int PropertyWithTwoMethods { get; set; }
        }

        [PatternTest(false)]
        public class NonOverrideableStrategy
        {
            public void NonOverrideableAction()
            {
            }
        }

        [PatternTest(false)]
        public class NonPublicStrategy
        {
            private void PseudoStrategy()
            {
            }
        }

        [PatternTest(true)]
        public class VirtualStrategy
        {
            public virtual int RealStrategy()
            {
                return 0;
            }
        }

        [PatternTest(true)]
        public abstract class Strategy
        {
            public abstract void Action();
        }
    }
}
